package com.yazi.mxz.job.controller;

import javax.annotation.Resource;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.myframework.smhj.jackson.result.StatusResult;
import com.yazi.mxz.common.service.StoreGoodsService;

@Controller("storeGoodsController")
@RequestMapping("/storeGoods")
public class StoreGoodsController {

	private static Logger log = LoggerFactory.getLogger(StoreGoodsController.class);
	
	@Resource
	StoreGoodsService storeGoodsService;

	@RequestMapping("/sync")
	@ResponseBody
	public StatusResult sync(@RequestBody SyncBody body) {
		log.debug("同步企业商品到店铺商品");
		StatusResult jsonResult = new StatusResult();
		try {
			storeGoodsService.editByGoodsId(body.getGoodsId(), body.getSync());
			jsonResult.setOk();
		} catch (Exception e) {
			log.warn("同步企业商品到店铺商品异常: ", e);
			jsonResult.setErrorMessage(e.getMessage());
		}
		return jsonResult;
	}
	
	public static class SyncBody {
		private long goodsId;
		private Long sync;
		public long getGoodsId() {
			return goodsId;
		}
		public void setGoodsId(long goodsId) {
			this.goodsId = goodsId;
		}
		public Long getSync() {
			return sync;
		}
		public void setSync(Long sync) {
			this.sync = sync;
		}
		
	}
}
